import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CostMaterialVO, CostMaterialForm, CostMaterialQuery } from '@/api/agriculture/costMaterial/types';

/**
 * 查询农资用量列表
 * @param query
 * @returns {*}
 */

export const listCostMaterial = (query?: CostMaterialQuery): AxiosPromise<CostMaterialVO[]> => {
  return request({
    url: '/agriculture/costMaterial/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询农资用量详细
 * @param costId
 */
export const getCostMaterial = (costId: string | number): AxiosPromise<CostMaterialVO> => {
  return request({
    url: '/agriculture/costMaterial/' + costId,
    method: 'get'
  });
};

/**
 * 新增农资用量
 * @param data
 */
export const addCostMaterial = (data: CostMaterialForm) => {
  return request({
    url: '/agriculture/costMaterial',
    method: 'post',
    data: data
  });
};

/**
 * 修改农资用量
 * @param data
 */
export const updateCostMaterial = (data: CostMaterialForm) => {
  return request({
    url: '/agriculture/costMaterial',
    method: 'put',
    data: data
  });
};

/**
 * 删除农资用量
 * @param costId
 */
export const delCostMaterial = (costId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/costMaterial/' + costId,
    method: 'delete'
  });
};
